package co.edu.usbcali.museo.modelo.dto;

import co.edu.usbcali.museo.modelo.Museo;
import co.edu.usbcali.museo.presentation.backEndBeans.MuseoView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura,
*
*/
public class MuseoDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String nombremuseo;
    private String codmuseo;
    private boolean rowSelected = false;
    private MuseoView museoView;
    private Museo museo;

    public Museo getMuseo() {
        return museo;
    }

    public String listener_update(ActionEvent e) {
        try {
            museoView.action_modifyWitDTO(((codmuseo == null) ||
                codmuseo.equals("")) ? null : new Long(codmuseo),
                ((nombremuseo == null) || nombremuseo.equals("")) ? null
                                                                  : new String(
                    nombremuseo));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        codmuseo = museo.getCodmuseo().toString();
        nombremuseo = (museo.getNombremuseo() != null)
            ? museo.getNombremuseo().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        codmuseo = museo.getCodmuseo().toString();
        nombremuseo = (museo.getNombremuseo() != null)
            ? museo.getNombremuseo().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setMuseo(Museo museo) {
        this.museo = museo;
    }

    public MuseoView getMuseoView() {
        return museoView;
    }

    public void setMuseoView(MuseoView museoView) {
        this.museoView = museoView;
    }

    public String getNombremuseo() {
        return nombremuseo;
    }

    public void setNombremuseo(String nombremuseo) {
        this.nombremuseo = nombremuseo;
    }

    public String getCodmuseo() {
        return codmuseo;
    }

    public void setCodmuseo(String codmuseo) {
        this.codmuseo = codmuseo;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
